package cn.lg.soar.system.auth.model;

import cn.lg.soar.system.auth.entity.Org;
import cn.lg.soar.system.auth.entity.Post;
import cn.lg.soar.system.auth.enums.PostSelectorTypeEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * @author luguoxiang
 * @date 2022/6/13
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
public class PostSelectorDTO {

    private Long id;

    private String name;

    private Object other;

    private PostSelectorTypeEnum type;

    private Integer descendantQuantity;

    public static PostSelectorDTO from(Post post) {
        if (post == null) {
            return null;
        }
        PostSelectorDTO dto = new PostSelectorDTO();
        dto.id = post.getId();
        dto.name = post.getName();
        dto.type = PostSelectorTypeEnum.POST;
        return dto;
    }

    public static PostSelectorDTO from(Org org) {
        if (org == null) {
            return null;
        }
        PostSelectorDTO dto = new PostSelectorDTO();
        dto.id = org.getId();
        dto.name = org.getName();
        dto.type = PostSelectorTypeEnum.ORG;
        dto.other = org.getType();
        return dto;
    }

}
